//快乐数
public class leetcode202 {

        public int submit(int n){
            int sum=0;
            while(n>0){
                int x=n%10;
                sum+=x*x;
                n=n/10;
            }
            return sum;
        }
        public boolean isHappy(int n) {
            int slow=n;
            int fast=submit(n);
            while(fast!=slow){
                slow=submit(slow);
                fast=submit(submit(fast));
            }
            return slow==1;
        }

}
